/**
 * Created with JetBrains WebStorm.
 * User: Chacha
 * Date: 12/06/13
 * Time: 13:34
 * To change this template use File | Settings | File Templates.
 */
var Action = function(){
    this.name = "Unknow";
    this.requirement;
    this.shownName = true;


}

Action.prototype = {



    distanceReq : function(object1, object2, maxDistance){

        var px = object1.x;
        var py = object1.y;

        var tx = object2.x;
        var ty = object2.y;



        console.log(px + " " + py + " " + " " + tx + " " + ty);
        console.log(((px - tx) * (px - tx)) - ((py - ty) * (py - ty)));
        var distance = Math.sqrt(Math.abs(((px - tx) * (px - tx)) + ((py - ty) * (py - ty))));

        console.log(distance);

        return distance < maxDistance;


    },

    checkMature : function(plant){
        if (plant.maturity.name == "mature")
            return true;
        return false;
    },

    checkOwnership : function(object1, object2){

        console.log("bibu" + object1.personage + object2.id);
        if(object1.personage == null)
            return false;

        console.log(object1.personage + " " + object2.id);
        if(object1.personage == object2.id){

            return true;
        }

        return false;


    },

    checkFreeTile : function(object1){
        console.log("p" +object1.plantation);
        if(object1.plantation == null)
            return true;

    },

    checkIfBuilding : function(object1){
        console.log("p" +object1.building);
        if(object1.building == null)
            return true;

    },

    checkEnoughMoney : function(object1, object2, key){


        console.log(object1[key]);
        console.log(object2.money);
        return object1[key] < object2.money

    },

    getDistanceFor : function(action){

        if (action == "plant"){

            console.log("on est dans if plant");

            return 300;
        }


    }


}